<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //利用构造函数创建类
        function Star(uname, age) {
            this.uname = uname;
            this.age = age;
            // this.sing = function () {
            //     console.log('I can dance')
            // }
        }
        //创建对象
        var dlz = new Star('带篮子', 18);
        var zxy = new Star('张学友', 19);
        // console.log(dlz);

        //打印构造函数
        // console.dir(Star)
        Star.prototype.sing = function () {
            console.log('i can dance')
        }
        // dlz.sing()
        // zxy.sing()
        //打印对象的原型，非对象
        console.log(dlz.__proto__);
        console.log(dlz.__proto__ === Star.prototype);  //true
        //打构造函数的原型对象
        console.log(Star.prototype);
    </script>
</body>

</html>